#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

typedef struct Person
{
	int num;
	int password;
}Person;

typedef struct ListNode
{
	Person one;
	struct ListNode* next;
}ListNode;

void ListPushBack(ListNode** pphead, Person x)
{
	assert(pphead);
	ListNode* newnode = (ListNode*)malloc(sizeof(ListNode));
	if (newnode == NULL)
		return;
	newnode->one.num = x.num;
	newnode->one.password = x.password;
	if (*pphead == NULL)
	{
		*pphead = newnode;
	}
	else
	{
		ListNode* tail = *pphead;
		while (tail->next != *pphead)
			tail = tail->next;
		tail->next = newnode;
	}
	newnode->next = *pphead;
}

void ListTest1()
{
	ListNode* plist = NULL;
	Person a = { 1, 2 }, b = { 3, 4 };
	ListPushBack(&plist, a);
	ListPushBack(&plist, b);

}

int main()
{
	ListNode* plist = NULL;
	int n, m;
	scanf("%d%d", &n, &m);

	Person* people = (Person*)malloc(n * sizeof(Person));
	if (people == NULL)
		return 0;
	for (int i = 0; i < n; i++)
	{
		people[i].num = i + 1;
		scanf("%d", &people[i].password);
		ListPushBack(&plist, people[i]);
	}
	int num = n;
	ListNode* target = plist;
	while (num > 0)
	{
		if (num == 1)
		{
			printf("%d ", target->one.num);
			free(target);
			target = NULL;
		}
		else
		{
			int count = (m - 1) % num;
			while (count > 0)
			{
				target = target->next;
				count--;
			}
			ListNode* prev = target;
			while (prev->next != target)
				prev = prev->next;
			prev->next = target->next;
			printf("%d ", target->one.num);
			m = target->one.password;
			free(target);
			target = prev->next;
		}
		num--;
	}
	return 0;
}